﻿using IPR_StudyMeetingMrgSys.Enums;
using IPR_StudyMeetingMrgSys.Extension;
using IPR_StudyMeetingMrgSys.Models;
using IPR_StudyMeetingMrgSys.ViewModel;
using log4net;
using System;
using System.Configuration;
using System.Data;
using System.Reflection;
using System.Web;
using System.Web.Http;

namespace IPR_StudyMeetingMrgSys.Controllers
{
    public class AppraisalController : ApiController
    {
        ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        IPR_StudyMeetingMrgSys.BLL.T_Project bll = new BLL.T_Project();
         
        [HttpGet]
        [Route("api/Appraisal/GetAppraisal")]
        public IHttpActionResult GetProType(string ProNo)
        {
            ResultMsg resultMsg = new ResultMsg();
            resultMsg.StatusCode = (int)StatusCodeEnum.Success;
            try
            {
                bool blexist = false;
                string sSql = "     select * from T_Appraisal where ProNo='"+ProNo+"' and IsDelete=0";
                DataSet dataSet = bll.GetQuery(sSql);
                if (dataSet != null)
                    if (dataSet.Tables.Count > 0)
                        if (dataSet.Tables[0].Rows.Count > 0)
                        {
                            resultMsg.Info = StatusCodeEnum.Success.GetEnumText();
                            resultMsg.Data = dataSet.Tables[0];
                            resultMsg.Count = dataSet.Tables[0].Rows.Count;
                            blexist = true;
                        }
                if (!blexist)
                {
                    resultMsg.Info = "未获取到相应数据";
                }
            }
            catch (Exception ex)
            {
                resultMsg.StatusCode = (int)StatusCodeEnum.Error;
                resultMsg.Info = StatusCodeEnum.Error.GetEnumText();
                resultMsg.Data = ex.Message;
                log.Error(ex);
            }
            return Json(resultMsg);
        }
        
    }
}
